package com.invoicerecognition.backend.controller.Invoice;

import com.alibaba.fastjson.JSONObject;
import com.invoicerecognition.backend.service.Invoice.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class InfoController {
    @Autowired
    private InfoService infoService;

    @GetMapping("/api/invoice/info/url")
    public JSONObject getInfoUrl(@RequestParam Map<String, String> data) {
        String imageData = data.get("imageData");
        String paramType = data.get("paramType");
        return infoService.getInfoUrl(imageData, paramType);
    }

    @PostMapping("/api/invoice/info/file")
    public JSONObject getInfoFile(@RequestParam("image") MultipartFile file) {
        return infoService.getInfoFile(file);
    }
}
